package conponent;

import module.EntityType;
import view.View;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 魔法球组件
 */
public class MagicBallComp extends EntityComp implements MagicBall{
    EntityComp owner;
    List<MagicProp> mpl;

    public MagicBallComp(){
        super();
        mpl=new ArrayList<MagicProp>();
    }
    public MagicBallComp(int x, int y, int w, int h, View loc, Image show) {
        super(x, y, w, h, loc, show);
    }


    @Override
    public void beforeCreated() {

        //mpl需要确保按照魔法词条的生效优先级进行排序，最高优先级在最前面
        for(MagicProp mp:mpl){
            mp.effect(this);
        }

    }

    @Override
    public void afterCollision(Entity et) {

    }

    @Override
    public List<MagicProp> getProperty() {
        return mpl;
    }

    @Override
    public void addMagicProp(MagicProp mp) {
        mpl.add(mp);
    }

    @Override
    public void addMagicProp(List<MagicProp> mpl) {
        this.mpl=mpl;
    }

    @Override
    public EntityComp getOwner() {
        return owner;
    }

    @Override
    public void setOwner(EntityComp ec) {
        owner=ec;
    }

    @Override
    public void run() {

    }

    @Override
    public EntityType getEntityType() {
        return EntityType.MagicBall;
    }
}
